Suppressing a dialog box when running an encrypted script

I have a file that is encrypted, when I run this file it will bring up a dialog box to browse and select a single file for import. I want to import multiple files from a folder instead of repeating the process for each one. Is there anyway I can suppress this dialog box given I cannot make any changes to the encrypted file?

 

Uma


UmaU - Thu Feb 05 07:56:27 EST 2015

Re: Suppressing a dialog box when running an encrypted script
Wolfgang Uhr - Thu Feb 05 09:36:40 EST 2015

Hi

Using dxl, there is no chance. The only possibility is to capture the window, fill the text control whith the file name and send a mouseclick to the ok button.

There are some routines which helps you to automatize this procedure, but in this case it depends of how familiare you are in other programming languages. There exists solutions in c, c#, java, visual basic (not Vb Script) and some others more.

You have to find the language, you want to realize the solution and perhaps a forum to discuss the further problems.

Maybe AutoIT delivers a solution. It's a script language which wraps the standard c-api's for windows. But I cannot say, if it delivers all routines you need or not. If it is complete (based on the requirements of your problem) then you will get a very nice and small solution.

Best regards

Wolfgang

 

Re: Suppressing a dialog box when running an encrypted script
UmaU - Thu Feb 05 17:25:24 EST 2015

Wolfgang Uhr - Thu Feb 05 09:36:40 EST 2015

Hi

Using dxl, there is no chance. The only possibility is to capture the window, fill the text control whith the file name and send a mouseclick to the ok button.

There are some routines which helps you to automatize this procedure, but in this case it depends of how familiare you are in other programming languages. There exists solutions in c, c#, java, visual basic (not Vb Script) and some others more.

You have to find the language, you want to realize the solution and perhaps a forum to discuss the further problems.

Maybe AutoIT delivers a solution. It's a script language which wraps the standard c-api's for windows. But I cannot say, if it delivers all routines you need or not. If it is complete (based on the requirements of your problem) then you will get a very nice and small solution.

Best regards

Wolfgang

 

Thanks Wolfgang. I just wanted to check if there was some way to do this through DXL that I was not aware of.

Thanks for the AutoIT tip, I'll see if anyone in the team is familar with it. 

Rgds,

Uma

 

 

Re: Suppressing a dialog box when running an encrypted script
Mathias Mamsch - Thu Feb 05 20:49:08 EST 2015

Of course you can change the behaviour of encrypted files to anything you like. The technique to apply here is to hook the DXL gui commands before including the encrypted file. Look on the forum for "automate export gui" to get examples there are numerous around.

If you have more questions, feel free to ask. Regards, Mathias

Re: Suppressing a dialog box when running an encrypted script
UmaU - Fri Feb 06 08:40:33 EST 2015

Mathias Mamsch - Thu Feb 05 20:49:08 EST 2015

Of course you can change the behaviour of encrypted files to anything you like. The technique to apply here is to hook the DXL gui commands before including the encrypted file. Look on the forum for "automate export gui" to get examples there are numerous around.

If you have more questions, feel free to ask. Regards, Mathias

Hi Mathias,

Would you be referring to your response here https://www.ibm.com/developerworks/community/forums/html/topic?id=cfcb1bca-0006-4f8a-a52c-3858d9505d47&ps=25

On running the encrypted script, it first pops up a DB to select the destination Folder in DOORS and then the next DB pops up to point to the location of the file to be imported. Can these be suppressed?

Forgive me if I sound ignorant, I'm using DOORS after a long break.

Uma

Re: Suppressing a dialog box when running an encrypted script
Mathias Mamsch - Fri Feb 06 15:38:00 EST 2015

UmaU - Fri Feb 06 08:40:33 EST 2015
Hi Mathias,

Would you be referring to your response here https://www.ibm.com/developerworks/community/forums/html/topic?id=cfcb1bca-0006-4f8a-a52c-3858d9505d47&ps=25

On running the encrypted script, it first pops up a DB to select the destination Folder in DOORS and then the next DB pops up to point to the location of the file to be imported. Can these be suppressed?

Forgive me if I sound ignorant, I'm using DOORS after a long break.

Uma

Hi Uma,

yes this is one example I am referring to...

Or this one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014878954

Or this one: https://www.ibm.com/developerworks/community/forums/html/topic?id=2c42c242-78a5-4097-8fc6-96b4afe8325a

Or that one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335

Or that one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014492977

The techique used is similar. You prevent the other dialog from blocking by overriding show, block, sometimes realize. You can fill in the dialog values, after realizing the dialog or directly call the API functions if existing.

The non-easy thing is to find out, which variables to use with an encrypted script or to get references to them. But I am not sure if this answers your question. Regards, Mathias

Re: Suppressing a dialog box when running an encrypted script
UmaU - Sat Feb 07 20:22:26 EST 2015

Mathias Mamsch - Fri Feb 06 15:38:00 EST 2015

Hi Uma,

yes this is one example I am referring to...

Or this one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014878954

Or this one: https://www.ibm.com/developerworks/community/forums/html/topic?id=2c42c242-78a5-4097-8fc6-96b4afe8325a

Or that one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335

Or that one: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014492977

The techique used is similar. You prevent the other dialog from blocking by overriding show, block, sometimes realize. You can fill in the dialog values, after realizing the dialog or directly call the API functions if existing.

The non-easy thing is to find out, which variables to use with an encrypted script or to get references to them. But I am not sure if this answers your question. Regards, Mathias

Hi Mathias,

  The problem here is I have no clue about the variables. The script is from the client and is completely encrypted. I tried tracing but couldn't really figure out the variables. Any ideas?

As long as you are reading this, could you also please let me know if there is a way to automate export from Word to DOORS?

Rgds

Uma

Re: Suppressing a dialog box when running an encrypted script
Wolfgang Uhr - Mon Feb 09 02:54:56 EST 2015

Mathias Mamsch - Thu Feb 05 20:49:08 EST 2015

Of course you can change the behaviour of encrypted files to anything you like. The technique to apply here is to hook the DXL gui commands before including the encrypted file. Look on the forum for "automate export gui" to get examples there are numerous around.

If you have more questions, feel free to ask. Regards, Mathias

Hello Mathias

Ok, let us have a look at this example ...

DB createDialog(string sDialogTitle, int iDialogType) {
    print "Dialog: " sDialogTitle "\n";
 return(create(sDialogTitle, iDialogType));
}

DBE createButton(DB dbDialog, string sButtonText, void fnctEventButtonClick(DBE)) {
 print "Dialog: " sButtonText "\n";
 return(button(dbDialog, sButtonText, fnctEventButtonClick));
}

void defineCloseFnctEvent(DB dbDialog, bool bIncludeButtonInDialog,  void fnctEventCloseDialog(DB)) {
 print "Close: " bIncludeButtonInDialog "\n";
 close(dbDialog, bIncludeButtonInDialog, fnctEventCloseDialog);
}

void realizeDialog(DB dbDialog) {
 print "realize\n";
 realize(dbDialog);
}

DB create(string sDialogTitle, int iDialogType) { return(createDialog(sDialogTitle, iDialogType)) };
DBE button(DB dbDialog, string sButtonText,  void fnctEventButtonClick(DBE)) { return(createButton(dbDialog, sButtonText, fnctEventButtonClick)) };
void close(DB dbDialog, bool bIncludeButtonInDialog,  void fnctEventCloseDialog(DB)) { defineCloseFnctEvent(dbDialog, bIncludeButtonInDialog, fnctEventCloseDialog) };
void realize(DB dbDialog) { realizeDialog(dbDialog) };

// ---------- Encrypted code --------------------------------

void myDialog_OK(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DB someDBE) { release(someDBE) };

void dialogDemo() {
 DB myDialog = create("Demo", styleCentered);
 DBE btnOk = button(myDialog, "Some ButtonText", myDialog_OK);
 DBE btnClose = button(myDialog, "Some other ButtonText", myDialog_Close);
 close(myDialog, false, myDialog_Close);
 
 realize(myDialog);
 block(myDialog);
 destroy(myDialog);
 // some code after dialog is closed ...
}

// -----------------------------------------------------------

dialogDemo();
// sendaClickToButton("Some ButtonText")

I have simulated a sequence "encrypted code", I've hooked some routines and then I use a documented external function (dialogDemo()) and now I want to send a click to one butten.

Of course, I can create a data structure filled by the controls from the hooked routines and of course, I know to implement a sendaClick-Routine. The problem is the block()-command which stops the excecution of the script at this time. So the code is never excecuted until someone really performs a click, even it is put into an eval_()-command.

Or let me say it in an other form: How can I start an other asynchron dxl script?

Best regards

Wolfgang

Re: Suppressing a dialog box when running an encrypted script
Mathias Mamsch - Mon Feb 09 04:25:27 EST 2015

Wolfgang Uhr - Mon Feb 09 02:54:56 EST 2015

Hello Mathias

Ok, let us have a look at this example ...

DB createDialog(string sDialogTitle, int iDialogType) {
    print "Dialog: " sDialogTitle "\n";
 return(create(sDialogTitle, iDialogType));
}

DBE createButton(DB dbDialog, string sButtonText, void fnctEventButtonClick(DBE)) {
 print "Dialog: " sButtonText "\n";
 return(button(dbDialog, sButtonText, fnctEventButtonClick));
}

void defineCloseFnctEvent(DB dbDialog, bool bIncludeButtonInDialog,  void fnctEventCloseDialog(DB)) {
 print "Close: " bIncludeButtonInDialog "\n";
 close(dbDialog, bIncludeButtonInDialog, fnctEventCloseDialog);
}

void realizeDialog(DB dbDialog) {
 print "realize\n";
 realize(dbDialog);
}

DB create(string sDialogTitle, int iDialogType) { return(createDialog(sDialogTitle, iDialogType)) };
DBE button(DB dbDialog, string sButtonText,  void fnctEventButtonClick(DBE)) { return(createButton(dbDialog, sButtonText, fnctEventButtonClick)) };
void close(DB dbDialog, bool bIncludeButtonInDialog,  void fnctEventCloseDialog(DB)) { defineCloseFnctEvent(dbDialog, bIncludeButtonInDialog, fnctEventCloseDialog) };
void realize(DB dbDialog) { realizeDialog(dbDialog) };

// ---------- Encrypted code --------------------------------

void myDialog_OK(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DB someDBE) { release(someDBE) };

void dialogDemo() {
 DB myDialog = create("Demo", styleCentered);
 DBE btnOk = button(myDialog, "Some ButtonText", myDialog_OK);
 DBE btnClose = button(myDialog, "Some other ButtonText", myDialog_Close);
 close(myDialog, false, myDialog_Close);
 
 realize(myDialog);
 block(myDialog);
 destroy(myDialog);
 // some code after dialog is closed ...
}

// -----------------------------------------------------------

dialogDemo();
// sendaClickToButton("Some ButtonText")

I have simulated a sequence "encrypted code", I've hooked some routines and then I use a documented external function (dialogDemo()) and now I want to send a click to one butten.

Of course, I can create a data structure filled by the controls from the hooked routines and of course, I know to implement a sendaClick-Routine. The problem is the block()-command which stops the excecution of the script at this time. So the code is never excecuted until someone really performs a click, even it is put into an eval_()-command.

Or let me say it in an other form: How can I start an other asynchron dxl script?

Best regards

Wolfgang

Hi Wolfgang,

to prevent the dialog from blocking you need to also hook the block function.

DB theDialogHandle = null
void block_old (DB dbDialog) { block dbDialog }
void block(DB dbDialog) { theDialogHandle= dbDialog; /* realizeDialog(dbDialog); */}

you can call realize from block, or simply do nothing. to prevent the dialog from being destroyed you also need to hook destroy

void destroy_old (DB dbDialog) { destroy dbDialog }
void destroy(DB dbDialog) {  }

Then the execution will just skip over block / destroy and you are free to append your own code. Problematic is always the following case:

// ---- encrypted script

// Allocate some resources, load data
loadResources() 

DB diag = build_complex_dialog(); 

block diag
destroy diag

//  Free all allocated resources ...
//  Once this has been executed, script will not function anymore
freeResources()

// ------------------ end encrypted script

In the above case, you would need to perform all your actions in the overridden block or destroy function to prevent the scripts resources to be freed. So you cannot simply let the script "skip over" the block / destroy commands ... Since however the block / destroy hooks must be placed ABOVE the encrypted program by definition, you have no access to any functions or global variables in the script. Working with forward declarations is error prone and can lead to crashes.

So it would have to be seen how to handle this kind of problem. I am sure it is "solvable" ... Regards, Mathias

 

Re: Suppressing a dialog box when running an encrypted script
Mathias Mamsch - Mon Feb 09 04:40:00 EST 2015

UmaU - Sat Feb 07 20:22:26 EST 2015

Hi Mathias,

  The problem here is I have no clue about the variables. The script is from the client and is completely encrypted. I tried tracing but couldn't really figure out the variables. Any ideas?

As long as you are reading this, could you also please let me know if there is a way to automate export from Word to DOORS?

Rgds

Uma

The easiest way to work out the variables of the program is to use the "unassigned" trick. You hook the dialog creation functions and return an unassigned variable. DXL will happily tell us the variable name. Take Wolfgangs example from below:

// The "unassigned trick": Return an unassigned value for the dialog box ...
DB create(string s, int x) { return ((addr_ (-2023406815)) DB) }

// ---------- Encrypted code --------------------------------

void myDialog_OK(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DB someDBE) { release(someDBE) };

void dialogDemo() {
 DB myDialog = create("Demo", styleCentered);
 DBE btnOk = button(myDialog, "Some ButtonText", myDialog_OK);
 DBE btnClose = button(myDialog, "Some other ButtonText", myDialog_Close);
 close(myDialog, false, myDialog_Close);
 
 realize(myDialog);
 block(myDialog);
 destroy(myDialog);
 // some code after dialog is closed ...
}


dialogDemo();

The above example returns an unassigned value instead of a dialog handle. So the next perm accessing the dialog box fails and we get the name of the variable (myDialog) ... Next we can test if this is a global variable or a local one by simply placing the variable below the code ... If it is global you can access it. If not you need to store it away.

// ---------- Encrypted code --------------------------------

...

// ---- end of encrypted script ... 

myDialog // yields a 'variable not found error', so its a local variable... 

So myDialog is local, we need to store it from the perm ...

// The "local -> global trick": we store the local variable in a global inside hooked perm
DB myDialogGlobal = null; 

DB create_old(string s, int x) { return create (s, x); }
DB create(string s, int x) { myDialogGlobal = create_old(s,x); return myDialogGlobal }

// ---------- Encrypted code --------------------------------
...
// ----------- end of encrypted code ...

This way you work your way through the code ... Cumbersome. But it works. Regards, Mathias

Re: Suppressing a dialog box when running an encrypted script
Mathias Mamsch - Mon Feb 09 06:12:31 EST 2015

Mathias Mamsch - Mon Feb 09 04:40:00 EST 2015

The easiest way to work out the variables of the program is to use the "unassigned" trick. You hook the dialog creation functions and return an unassigned variable. DXL will happily tell us the variable name. Take Wolfgangs example from below:

// The "unassigned trick": Return an unassigned value for the dialog box ...
DB create(string s, int x) { return ((addr_ (-2023406815)) DB) }

// ---------- Encrypted code --------------------------------

void myDialog_OK(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DBE someDBE) { release(getParent(someDBE)) };
void myDialog_Close(DB someDBE) { release(someDBE) };

void dialogDemo() {
 DB myDialog = create("Demo", styleCentered);
 DBE btnOk = button(myDialog, "Some ButtonText", myDialog_OK);
 DBE btnClose = button(myDialog, "Some other ButtonText", myDialog_Close);
 close(myDialog, false, myDialog_Close);
 
 realize(myDialog);
 block(myDialog);
 destroy(myDialog);
 // some code after dialog is closed ...
}


dialogDemo();

The above example returns an unassigned value instead of a dialog handle. So the next perm accessing the dialog box fails and we get the name of the variable (myDialog) ... Next we can test if this is a global variable or a local one by simply placing the variable below the code ... If it is global you can access it. If not you need to store it away.

// ---------- Encrypted code --------------------------------

...

// ---- end of encrypted script ... 

myDialog // yields a 'variable not found error', so its a local variable... 

So myDialog is local, we need to store it from the perm ...

// The "local -> global trick": we store the local variable in a global inside hooked perm
DB myDialogGlobal = null; 

DB create_old(string s, int x) { return create (s, x); }
DB create(string s, int x) { myDialogGlobal = create_old(s,x); return myDialogGlobal }

// ---------- Encrypted code --------------------------------
...
// ----------- end of encrypted code ...

This way you work your way through the code ... Cumbersome. But it works. Regards, Mathias

Another nice trick is to produce a couple of syntax errors on the script. We will execute in an eval_ so we can get all the DXL error messages.

To get for example all global variables of the script, you can simply wrap the script inside a function and execute checkDXL.

string s = "
void func() {
#include <standard/export/office/word.dxl>
}
"

string sErr = checkDXL s; print sErr

You will get a list of all global variables. You can also mess with function declarations (make them a variable) or stuff like that to get some revealing error messages about functions, etc. You can get the type of those global variables too, by assigning different Kinds of variables to them and see, when the error goes away.

Hope that gives you some ideas. Regards, Mathias

Re: Suppressing a dialog box when running an encrypted script
UmaU - Tue Feb 17 14:21:11 EST 2015

Mathias Mamsch - Mon Feb 09 04:25:27 EST 2015

Hi Wolfgang,

to prevent the dialog from blocking you need to also hook the block function.

DB theDialogHandle = null
void block_old (DB dbDialog) { block dbDialog }
void block(DB dbDialog) { theDialogHandle= dbDialog; /* realizeDialog(dbDialog); */}

you can call realize from block, or simply do nothing. to prevent the dialog from being destroyed you also need to hook destroy

void destroy_old (DB dbDialog) { destroy dbDialog }
void destroy(DB dbDialog) {  }

Then the execution will just skip over block / destroy and you are free to append your own code. Problematic is always the following case:

// ---- encrypted script

// Allocate some resources, load data
loadResources() 

DB diag = build_complex_dialog(); 

block diag
destroy diag

//  Free all allocated resources ...
//  Once this has been executed, script will not function anymore
freeResources()

// ------------------ end encrypted script

In the above case, you would need to perform all your actions in the overridden block or destroy function to prevent the scripts resources to be freed. So you cannot simply let the script "skip over" the block / destroy commands ... Since however the block / destroy hooks must be placed ABOVE the encrypted program by definition, you have no access to any functions or global variables in the script. Working with forward declarations is error prone and can lead to crashes.

So it would have to be seen how to handle this kind of problem. I am sure it is "solvable" ... Regards, Mathias

 

Thank you Mathias and Wolfgang for your inputs. I have not had the time to try this due to other high priority issues. For the time being I have asked the client if the script developer can give me the variable names and functions. This buys me some time to check out your above responses. Thanks again for your detailed responses.

Will get back to you if I have had some luck or if I have some questions.

Your help is much appreciated.